package com.quanyou.week.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.quanyou.base.framework.model.LightningResponse;
import com.quanyou.controller.ApiController;
import com.quanyou.user.service.UserService;
import com.quanyou.user.vo.UserVo;
import com.quanyou.utils.ErrorCode;
import com.quanyou.utils.Utility;
import com.quanyou.week.service.WeekHeadService;
import com.quanyou.week.vo.WeekHeadVo;

/**
 * 
 * @Title: WeekHeadController.java
 * @Package com.quanyou.week.controller
 * @Description: 周计划&总结等接口
 * @author yuanjie
 * @date 2017年7月7日 上午11:09:42
 * @version V1.0
 */
@RestController
@RequestMapping("/api/weekhead/v1")
public class WeekHeadController extends ApiController {

	@Autowired
	private WeekHeadService weekHeadService;
	@Autowired
	private UserService userService;

	/**
	 * 获取我的周计划和总结
	 * 
	 * @return
	 */
	@RequestMapping("/findMeWeekHeads")
	public LightningResponse findMeWeekHeads(WeekHeadVo weekHeadVo) {
		logger.debug("[weekHead,findMeWeekHeads,begin,req:{}]", weekHeadVo);
		LightningResponse lightningResponse;
		try {
			if (null == weekHeadVo.getAccount()) {
				// 用户账户为空
				lightningResponse = Utility.getErrorResponse(
						ErrorCode.USER_NOT_FOUND, resourceBundle);
				return lightningResponse;
			}
			// 查询用户信息
			UserVo userVo = userService.getUserByAccount(weekHeadVo
					.getAccount());
			if (null == userVo) {
				// 没有查到数据
				lightningResponse = Utility.getErrorResponse(
						ErrorCode.USER_NOT_FOUND, resourceBundle);
				return lightningResponse;
			}
			lightningResponse = Utility.getRightResponse("success", weekHeadVo);
			logger.debug("[region,list,end,req:{},resp:{}]", weekHeadVo,
					lightningResponse);

		} catch (Exception e) {
			e.printStackTrace();
			lightningResponse = Utility.getErrorResponse(ErrorCode.SYS_FAIL,
					resourceBundle);
		}
		return lightningResponse;

	}
}
